/**
 * 
 */
package com.chainwintel.prjmgmt.repository;

import java.io.Serializable;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

/**
 * @author dearshor
 *
 */
@Repository
public class GenericRepositoryImpl<T> implements GenericRepository<T>, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3567167594330402046L;
	@PersistenceContext 
	private EntityManager em;
	
	protected EntityManager getEntityManager() {
		return em;
	}

	public T find(Class<T> clazz, Serializable id) throws DataAccessException {
		// TODO Auto-generated method stub
		return em.find(clazz, id);
	}

	public T merge(T obj) throws DataAccessException {
		// TODO Auto-generated method stub
		return em.merge(obj);
	}

	public void persist(T obj) throws DataAccessException {
		// TODO Auto-generated method stub
		em.persist(obj);
	}

	public void remove(T obj) throws DataAccessException {
		// TODO Auto-generated method stub
		em.remove(obj);
	}

}
